<?php

session_start();
include_once '../conf/conf.php';
$id = $_SESSION['id'];
$name = $_SESSION['name'];
$sex = $_SESSION['sex']; if ($sex == 'Male'){$y0 = '78'; $y1 = '455';} if ($sex == 'Female'){$y0 = '7'; $y1 = '429';}
$dob = $_SESSION['dob'];
$xa = strtotime($dob);
$x0 = $xa + (86400*1826);
$x1 = $xa + (86400*6939);
      $sql = "SELECT encount.enc_id,encdate, height FROM encount, clinical WHERE encount.id = '$id' AND encount.enc_id = clinical.enc_id AND clinical.height != '' ORDER BY encdate DESC";
      $res = mysqli_query($con, $sql) or die("sorry, database is updating...");
$htdata = array();
while ($row = mysqli_fetch_array($res)) {
  $date = $row['encdate'];
  $f_date = strtotime($date);
  $htdata[] = array('', $f_date, $row['height']);
}
mysqli_free_result($res);
mysqli_close($con);

include('phplot.php');

$kit = new PHPlot(800, 500);
$kit->SetBackgroundColor('ivory');
$kit->SetTransparentColor('ivory');
$kit->SetImageBorderType('plain');

$kit->SetPlotAreaPixels(58, $y0, 734, $y1);
$kit->SetPlotAreaWorld($x0, 100, $x1, 180);
$kit->SetDataValues($htdata);

$kit->SetPlotType('linepoints');
$kit->SetDataType('data-data');
//$kit->SetXLabelAngle(90);
//$kit->SetXLabelType('time', '%Y-%m-%d');
$kit->SetDataColors(array('blue'));
//$kit->SetXTickIncrement(2623000);
//$kit->SetYTickIncrement(10);
$kit->SetPointSizes(8);
$kit->SetLineWidth(2);

$kit->SetDrawXAxis(FALSE);
$kit->SetDrawYAxis(FALSE);
$kit->SetXDataLabelPos('none');
$kit->SetYDataLabelPos('none');
$kit->SetDrawXGrid(FALSE);
$kit->SetDrawYGrid(FALSE);
$kit->SetXTickPos('none');
$kit->SetXTickLabelPos('none');
$kit->SetYTickPos('none');
$kit->SetYTickLabelPos('none');
$kit->DrawGraph();

?>